package com.xingkeduo.business.operation.domain.cms;

import com.google.common.collect.Lists;
import com.xingkeduo.business.operation.service.PermsService;
import com.xingkeduo.pojo.query.PermsQuery;
import com.xingkeduo.pojo.table.PermsTable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * 文件概述
 *
 * @author wangxilong <wangxilong@xingkeduo.com>
 * @version id:v0.1 19-1-17 下午6:56
 * @package BeautyOS
 * @copyright Copyright (c) XKD 2019
 */
@Component
public class MenuDomain {
    @Autowired
    private PermsService permsService;


    public List<PermsTable> getMenu(Integer userId) throws Throwable {
        //1.获取顶级菜单模块
        PermsQuery permsTopQuery = new PermsQuery();
        permsTopQuery.setPid(0L).setType(1);
        List<PermsTable> selectTopLists = permsService.selectLists(permsTopQuery);

        // 3.查询当前用户所有菜单类型(type=2)的菜单
        PermsQuery permsQuery = new PermsQuery();
        permsQuery.setType(2);
        List<PermsTable> type2PermsList = permsService.selectLists(permsQuery);

        List<PermsTable> userPermissionType2List = Lists.newArrayList();  // 当前用户所拥有的二级菜单

        for(PermsTable entity : type2PermsList) {
            //TODO 处理用户权限对象
            userPermissionType2List.add(entity);
        }

        // 4.获取一级菜单和子菜单
        List<PermsTable> permsTableList = Lists.newArrayList();

        return permsTableList;
    }




}
